import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/Table';
import { airportList } from '@apps/ant-bus/src/views/business/airport/data/api';
import { render } from '@apps/antd-admin/src/hooks/render/renderUtils';

export const columns: BasicColumn[] = [
  {
    title: '创建日期',
    dataIndex: 'createTime',
    width: 150,
  },
  {
    title: '机场',
    dataIndex: 'airportName',
    width: 120,
  },
  {
    title: '用户账号',
    dataIndex: 'mainAccount',
    width: 120,
  },
  {
    title: '销售账户',
    dataIndex: 'employeeAccount',
    width: 120,
  },
  {
    title: '销售姓名',
    dataIndex: 'employeeName',
    width: 100,
  },
  {
    title: '订单号',
    dataIndex: 'orderNo',
    width: 120,
  },
  {
    title: '支付凭证',
    dataIndex: 'payVoucherImg',
    width: 120,
    customRender: render.renderImage,
  },
  {
    title: '线下支付方式',
    dataIndex: 'paywayName',
    width: 120,
  },
  {
    title: '状态',
    dataIndex: 'isCheck',
    width: 120,
    customRender: ({ record }: Recordable) => {
      const isCheckArray = [
        { label: '销售未确认', value: '1' },
        { label: '销售已确认', value: '2' },
        { label: '财务已确认', value: '3' },
        { label: '财务已冻结', value: '4' },
      ];
      const isCheck: any = isCheckArray.find(item => item.value == record.isCheck);
      if (isCheck) {
        return isCheck.label;
      }
      return '';
    },
  },
  {
    title: '备注',
    dataIndex: 'remark',
    width: 180,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'startDate',
    label: '开始日期',
    component: 'DatePicker',
    colProps: { span: 4 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'endDate',
    label: '结束日期',
    component: 'DatePicker',
    colProps: { span: 4 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'mainAccount',
    label: '用户账号',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'orderNo',
    label: '订单编号',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'isCheck',
    label: '审核状态',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      options: [
        { label: '销售未确认', value: 1 },
        { label: '销售已确认', value: 2 },
        { label: '财务已确认', value: 3 },
        { label: '财务已冻结', value: 4 },
      ],
    },
  },
  {
    field: 'airportId',
    label: '机场',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: {
      api: airportList,
      params: { handlerName: 'busAirportRoleListHandler' },
      labelField: 'airportName',
      valueField: 'airportId',
      immediate: true,
      showSearch: true,
    },
  },
];
